using MovieApi.DB;
using Microsoft.EntityFrameworkCore;
using MovieApi.Model;
using MovieApi.Interfaces;
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddControllers();

var connString = builder.Configuration.GetConnectionString("mysql");
builder.Services.AddDbContext<ApiDbContext>(x =>
{
    x.UseMySql(connString, ServerVersion.AutoDetect(connString));
});

builder.Services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.MapControllers();

app.Run();